<?php

namespace app\admin\controller;

class CreateVideo extends Main
{
    /**
     * 合成视频记录
     */
    public function index(){
        $_GPC = input();
        $page = max(intval($_GPC['page']), 1);
        $limit = max(intval($_GPC['limit']), 1);
        $row = new \app\commons\model\CreateVideo();
        $row = $row->where('sale_id', $_GPC['id']);
        $count = $row->count();
        $data = $row->page($page, $limit)->order('createtime', 'DESC')->select();
//        $data = $row->paginate($page);
        jsonpp($data, $count);
    }

    /**
     * 删除创建视频记录
     */
    public function del(){
        $_GPC = input();
        $id = $_GPC['id'] ?? 0;
        if(!$id) jsont([],1,'参数错误！');
        $res = \app\commons\model\CreateVideo::destroy(function ($query) use($id){
            $query->where('id','in',$id);
        });
        if(!$res) jsont([],1,'删除失败！');
        jsont([],0,'删除成功！');
    }
}